# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-mirage-flow
_pkgname=mirage-flow
pkgver=3.0.0
pkgrel=0
pkgdesc="Flow implementations and combinators for MirageOS"
url="https://github.com/mirage/mirage-flow"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="
	ocaml-runtime
	ocaml-cstruct
	ocaml-fmt
	ocaml-lwt
	ocaml-logs
	ocaml-mirage-clock
	"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-cstruct-dev
	ocaml-fmt-dev
	ocaml-lwt-dev
	ocaml-logs-dev
	ocaml-mirage-clock-dev
	"
makedepends="$depends_dev dune ocaml"
checkdepends="ocaml-alcotest-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirage/mirage-flow/releases/download/v$pkgver/mirage-flow-v$pkgver.tbz"
builddir="$srcdir/$_pkgname-v$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
2aeb397799621bc0ea2485b68058949c99b3da8d454939d594a9b2d39ef47aa2c16489f06adfa2dea3b34fd15e60a23abc6b8e214dfbc8b7da2e958de7c36b57  ocaml-mirage-flow-3.0.0.tar.bz2
"
